//
//  YCIAPManager.h
//  IAPManager
//
//  Created by 唐可雄 on 2019/3/6.
//  Copyright © 2019年 swustyc. All rights reserved.
//

#import <Foundation/Foundation.h>

#import <StoreKit/StoreKit.h>

typedef NS_ENUM(NSInteger, YCIAPResult) {
    YCIAPResultNotAllow,        // 设备未启用程序内购买
};

NS_ASSUME_NONNULL_BEGIN

@protocol YCIAPManagerDelegate <NSObject>

- (void)transactWithResult:(YCIAPResult)result;
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response;

@end

/**
 内购管理器
 */
@interface YCIAPManager : NSObject<SKPaymentTransactionObserver, SKProductsRequestDelegate>

@property (nonatomic, assign) id<YCIAPManagerDelegate> delegate;

/**
 根据多个内购产品ID获取各自的产品信息

 @param productIds 内购产品ID列表
 */
- (SKProductsRequest *)requestProductsInfo:(NSSet *)productIds;
/**
 购买某个内购产品

 @param product 内购产品
 */
- (void)purchaseProduct:(SKProduct *)product;

- (void)resumeTask;

@end

NS_ASSUME_NONNULL_END
